package com.my.springframework.context.event;

import com.my.springframework.beans.factory.BeanFactory;
import com.my.springframework.context.ApplicationEvent;
import com.my.springframework.context.ApplicationListener;

/**
 * @author sk
 * @description
 * @since 2021-11-29
 **/
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    /**
     * Multicast the given application event to appropriate listeners.
     *
     * @param event the event to multicast
     */
    @SuppressWarnings("unchecked")
    @Override
    public void multicastEvent(ApplicationEvent event) {
        for (final ApplicationListener listener : getApplicationListeners(event)) {
            listener.onApplicationEvent(event);
        }
    }
}
